<template>
  <div class="smart-remind-drawer">
    <el-drawer
      :title="certificateType"
      :visible.sync="drawer"
      direction="rtl"
      :modal-append-to-body="false"
      :show-close="false"
      :wrapperClosable="false"
      size="30%"
    >
      <div class="smart-remind-content">
        <el-input v-model="value" placeholder="搜索编号" class="search" />
        <el-table :data="tableData" style="width: 93%; margin: 80px auto 0">
          <el-table-column label="序号" width="100" align="center">
            <template slot-scope="scope">{{ scope.$index + 1 }}</template>
          </el-table-column>
          <el-table-column label="类型" prop="type"> </el-table-column>
          <el-table-column label="编号" sortable prop="id"> </el-table-column>
          <el-table-column label="土地证编号" prop="tudiId"> </el-table-column>
          <el-table-column fixed="right" label="操作" width="100">
            <template slot-scope="scope">
              <el-button type="text" size="small">查看附件</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="smart-btn" @click="closeClick">关闭</div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
export default {
  props: {
    drawer: {
      type: Boolean,
      default: false,
    },
    forBaseInfo: {
      type: Object,
    },
    certificateType: {
      type: String,
    },
  },
  data() {
    return {
      value: "",
      tableData: [],
      search: "",
      propertyinfoStorage: null,
    };
  },
  watch: {
    forBaseInfo: {
      handler(val) {
        this.tableData = [];
        if (this.propertyinfoStorage.propertyId) {
          if (this.certificateType == "不动产权证") {
            this.tableData = val.immovablePropertyCertificateAttachList;
            console.log(
              "不动产权证",
              val.immovablePropertyCertificateAttachList
            );
          } else if (this.certificateType == "房产证") {
            this.tableData = val.houseOwnershipCertificateAttachList;
          } else if (this.certificateType == "土地证") {
            this.tableData = val.landCertificateAttachList;
          }
        }
      },
    },
  },
  mounted() {
    this.propertyinfoStorage = JSON.parse(localStorage.getItem("propertyinfo"));
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    closeClick() {
      this.$emit("update:drawer", false);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "~@/styles/mixin.scss";

.smart-remind-drawer {
  position: relative;
  .title-tips {
    position: absolute;
    top: 10px;
    left: 100px;
    font-size: 12px;
    color: #88909b;
  }
  .search {
    width: 50%;
    position: absolute;
    right: 20px;
    top: 80px;
  }
  .smart-remind-content {
    .smart-btn {
      @include searchBtn;
      margin-top: 50px;
      margin-left: 25px;
    }
  }
}
</style>

<style lang="scss">
.smart-remind-drawer {
  .el-drawer__header {
    background-color: #fafafa;
    padding: 19px 23px;
    color: #000;
    margin-bottom: 5px;
  }
}
</style>